﻿<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

@if (false) { 
<script src="../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
 } 

<script src="@Url.Content("~/Scripts/jquery-1.4.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.9.custom.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.json-2.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Core.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".button-delete").click(function () {
            var data = $(':input[Name="Id"]').serializeArray();

            $.ajax({
                type: 'POST',
                data: data,
                url: '@Url.Action("Delete", (string) this.ViewContext.RouteData.Values["controller"],
                                    new {area = this.ViewContext.RouteData.DataTokens["area"]})',
                success: function(result) {
                    $(".dialog-delete").dialog('close');
                    UpdateList(result);
                    CheckButton();
                }
            });
        });

        CheckButton();
    });

        function IsAnyChecked() {
        var b = false;
        $(".check").each(function () {

            if (b) {
                return;
            }

            b = ($(this).is(":checked"));

            if (b) {
                b = true;
            }
        });

        return b;
    }

    function CheckButton() {
        if (IsAnyChecked()) {
            $(".submit-delete").removeAttr("disabled");
            $(".submit-delete").attr("enabled", "enabled");
        }
        else {
            $(".submit-delete").removeAttr("enabled");
            $(".submit-delete").attr("disabled", "disabled");
        }
    }

    function UpdateList(result)
    {
        $('#list').html(result);
        $('#success').show();
        $("#success").addClass("success");
        $("#success").delay(5000).fadeOut(500);
    }
</script>
